﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DataWorks_Tools.HalfHourCalSave.Common.Basic
{
    public static class Distance
    {
        /// <summary>
        /// 只返回单个里程，不返回累积里程
        /// </summary>
        /// <param name="speed"></param>
        /// <param name="time"></param>
        /// <returns></returns>
        public static async Task< List<double>> ReturnSingleDistance(List<double> speed, List<double> time)
        {
            List<double> Distance = new List<double>
            {
                0
            };
            double singledistance;
            await Task.Run(() => {

                for (int i = 0; i < speed.Count - 1; i++)
                {
                    singledistance = (speed[i] + speed[i + 1]) * (time[i + 1] - time[i]) / 2 / 3.6;
                    Distance.Add(singledistance);
                }

            });
            return Distance;
        }
    }
}
